//
// Created by zpf on 2023/5/15.
//

#ifndef UKUI_SNI_WATCHER_PRIVATE_H
#define UKUI_SNI_WATCHER_PRIVATE_H

#include <QObject>
#include <QDBusContext>
#include <QStringList>
#include <QDBusServiceWatcher>
#include <QSet>

class WatcherPrivate : public QObject, protected QDBusContext
{
    Q_OBJECT
    Q_PROPERTY(QStringList RegisteredStatusNotifierItems READ RegisteredStatusNotifierItems)
    Q_PROPERTY(bool IsStatusNotifierHostRegistered READ IsStatusNotifierHostRegistered)
    Q_PROPERTY(int ProtocolVersion READ ProtocolVersion)
public:
    explicit WatcherPrivate(QObject *parent = nullptr);
    ~WatcherPrivate() override;

    QStringList RegisteredStatusNotifierItems() const;
    bool IsStatusNotifierHostRegistered() const;
    int ProtocolVersion() const;

public Q_SLOTS:
    void RegisterStatusNotifierItem(const QString &service);
    void RegisterStatusNotifierHost(const QString &service);

Q_SIGNALS:
    void StatusNotifierItemRegistered(const QString &service);
    void StatusNotifierHostRegistered();
    void StatusNotifierItemUnregistered(const QString &service);
    void StatusNotifierHostUnregistered();

private:
    void serviceUnregistered(const QString &service);

    QDBusServiceWatcher *m_serviceWatcher = nullptr;
    QStringList m_registeredServices;
    QSet<QString> m_statusNotifierHostServices;
};


#endif //UKUI_SNI_WATCHER_PRIVATE_H
